/**
 * 转正接口
 */
import request from '@/utils/request';
import { LIST_TYPE } from '../constants';

/**
 * 获取转正管理列表
 * @param {*} params
 */
export function queryInformalList(params) {
    const { type, ...rest } = params;
    let url = '/api/regular/v1/probation/probationer';
    switch (type) {
        case LIST_TYPE.INFORMAL:
            url = '/api/regular/v1/probation/wait_regular';
            break;
        case LIST_TYPE.RECORD:
            url = '/api/regular/v1/probation/history';
            break;
        default:
            break;
    }
    return request(url, {
        method: 'POST',
        data: { ...rest }
        // encryption: false
    });
}

/**
 * 获取转正记录详情
 * @param {*} regularProbationId
 */
export function getInformalDetail(regularProbationId) {
    return request(`/api/regular/v1/probation/${regularProbationId}`, {
        method: 'GET'
    });
}

/**
 * 获取转正过程记录列表
 * @param {*} employeeCode
 */
export function getTrialInfoList(employeeCode) {
    return request(`/api/regular/v1/probation/${employeeCode}/process_records`, {
        method: 'GET'
    });
}

/**
 * 获取转正试用期考评记录信息
 * @param {*} employeeCode
 */
export function getAssessRecords(employeeCode) {
    return request(`/api/regular/v1/probation/${employeeCode}/assess_records`, {
        method: 'GET'
    });
}

/**
 * 获取审批信息
 * @param {*} processInstanceId
 */
export function getProcessInfo(processInstanceId) {
    return request(`/api/workflowweb/processinstance/v1/getMyTask/${processInstanceId}`, {
        method: 'GET'
    });
}

/**
 * 获取转正员工信息
 * @param {*} employeeCode
 */
export function getInformalEmployeeInfo(employeeCode) {
    return request(`/api/regular/v1/probation/detail/${employeeCode}`, {
        method: 'GET'
    });
}

/**
 * 获取反馈数量
 * @param {*} regularProbationId
 */
export function getFeedbackNum(regularProbationId) {
    return request(`/api/regular/v1/probation/feedbacks/${regularProbationId}/interview_feedbacks_count`, {
        method: 'GET'
    });
}

/**
 * 获取反馈列表
 * @param {*} regularProbationId
 */
export function getFeedbackList(regularProbationId) {
    return request(`/api/regular/v1/probation/feedbacks/${regularProbationId}/interview_feedbacks`, {
        method: 'POST',
        data: { regularProbationId }
    });
}

/**
 * 新增反馈
 * @param {*} params
 */
export function addFeedback(params) {
    return request('/api/regular/v1/probation/feedbacks/actions/save_feedback_interview', {
        method: 'POST',
        data: params
    });
}

/**
 * 通过 employeeCode 获取转正流程详情
 * @param {*} params
 */
export function getInformalDetailByCode(params) {
    return request('/api/regular/v1/probation/assess/actions/detail', {
        method: 'POST',
        data: params
    });
}

/**
 * 通过 id 获取转正详情快照
 * @param {*} params
 */
export function getInformalSnapshotById({ id = '' }) {
    return request(`/api/regular/v1/probation/process_records/${id}`, {
        method: 'GET'
    });
}

/**
 * 更新转正流程详情
 * @param {*} params
 */
export function updateInformal(params) {
    return request('/api/regular/v1/probation/assess/actions/save', {
        method: 'POST',
        data: params
    });
}

/**
 * 获取能力评估表
 * @param {*} params
 */
export function getAssessmentForms(organizationCode) {
    return request(`/api/regular/v1/probation/ability_evaluation/listByOrganizationCode/${organizationCode}`, {
        method: 'GET'
    });
}
